import { MailerService } from '@nestjs-modules/mailer';
import { Inject, Injectable } from '@nestjs/common';
import { SentMessageInfo } from 'nodemailer';

@Injectable()
export class MailService {
  @Inject()
  mailerService: MailerService;

  async sendMail(to: string, text: string) {
    // 难崩，这个sentMessageInfo就是any，只能ignore了
    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
    const res: SentMessageInfo = await this.mailerService.sendMail({
      to,
      text,
    });
    // eslint-disable-next-line @typescript-eslint/no-unsafe-return
    return res;
  }
}
